import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';


void main()=>runApp(
    MaterialApp(
        home: Scaffold(
          body: MyApp(),
        ),
      theme: ThemeData(
        primarySwatch: Colors.yellow,
        textTheme: TextTheme(),
        buttonTheme: ButtonThemeData(buttonColor: Colors.yellow),
      ),
    )
);

class MyApp extends StatefulWidget {

  FToast fToast =  FToast();
  void onPressed() {
    fToast.showToast(
      child: Text("你点击了我",style: TextStyle()),
      gravity: ToastGravity.CENTER,
      toastDuration: Duration(milliseconds:500),
    );
  }

  @override
  State<StatefulWidget> createState() {
    return _MyAppState();
  }

}

class _MyAppState extends State<MyApp> {

  @override
  Widget build(BuildContext context) {
    widget.fToast.init(context);
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        // "漂浮"按钮
        ElevatedButton(
            onPressed: widget.onPressed,
            child: Text("\"漂浮\"按钮")
        ),
        TextButton(
          child: Text("normal"),
          onPressed: widget.onPressed,
        ),
        OutlinedButton(
          child: Text("normal"),
          onPressed: widget.onPressed,
        ),
        GestureDetector(
          child: IconButton(
            icon: Icon(Icons.thumb_up),
            onPressed: widget.onPressed,
          ),
          onLongPress: ()=>{
            widget.fToast.showToast(
              child: Text("你长按了我",style: TextStyle()),
              gravity: ToastGravity.CENTER,
              toastDuration: Duration(milliseconds:500),
            )
          },
        ),
        ElevatedButton.icon(
          icon: Icon(Icons.send),
          label: Text("发送"),
          onPressed: widget.onPressed,
        ),
        OutlinedButton.icon(
          icon: Icon(Icons.add),
          label: Text("添加"),
          onPressed: widget.onPressed,
        ),
        TextButton.icon(
          icon: Icon(Icons.info),
          label: Text("详情"),
          onPressed: widget.onPressed,
        ),
      ],
    );
  }

}







